/*
*	ID : pallab81
* 	PROG : 3015
* 	LANG : C++
* 	2011-10-06-00.27.17 Thursday
*
* 	"I have not failed, I have just found 10000 ways that won't work.
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>
#include <cstdlib>

using namespace std;

#define VI vector< int >
#define CI( x ) scanf("%d",&x)
#define CL( x ) scanf("%lld",&x)
#define CD( x ) scanf("%lf",&x )
#define foR(i,st,ed) for(int i = st ; i < ed ; ++i )
#define fo(i,ed) foR( i , 0 , ed )
#define foE(i,st,ed) for(int i = st ; i <= ed ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )

inline void wait(double seconds) {
    double endtime = clock()+(seconds * CLOCKS_PER_SEC);
    while (clock() < endtime) {
        ;
    }
}
Int N;
Int K;
inline void Read(){
    CL(N);
    CL(K);
}
int kase=1;
Int dp[ 65 ][ 33 ][ 33 ][ 101 ];
Int go(int zero, int one, int left, Int me){
    if( left == -1 ){
        return ( me ==0 ? 1LL : 0LL ) ;
    }
    if( dp[ left ][ zero ][ one ][ me ]!=-1 ){
        return dp[ left ][ zero ][ one ][ me ];
    }
    Int res = 0;

        if( left+1 == N ){
            if( one-1>=0 ){
                Int var = go( zero, one-1, left-1, ( me+(1LL<<left) )%K );
                res=var;
            }
        }
        else{
            if( zero-1 >=0 ){
                Int var1 = go( zero-1, one, left-1, me );
                res = res + var1;
            }
            if( one-1 >=0 ){
                Int var2 = go( zero, one-1, left-1, ( me+(1LL<<left) )%K );
                res = res + var2;
            }

        }
        dp[ left ][ zero ][ one ][ me ]  = res;
    return res;
}
inline void Proc(){
    int zero = N/2;
    int one = N/2;
    int left = N-1;
    Int me = 0;
    SET( dp, -1 );
    printf("Case %d: ",kase);
    if( zero!=one || K==0  ){
        cout<<0<<"\n";
    }
    else{
        Int var = go( zero, one, left, me );
        cout<<var<<"\n";
    }
    ++kase;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("in", "rt", stdin);
    freopen("out", "wt", stdout );
#endif

    int cases = 1;
    for ( CI(cases) ; cases; --cases) {
        Read();
        Proc();
    }

    return 0;
}
